// 门店申请相关 API
class StoreApplyApi {
    constructor(apiService) {
        this.api = apiService;
    }

    // 获取申请列表
    getList(params = {}) {
        return this.api.get('/admin/store-apply/list', params);
    }

    // 获取申请详情
    getDetail(id) {
        return this.api.get(`/admin/store-apply/${id}`);
    }

    // 审核通过
    approve(id, data = {}) {
        return this.api.post(`/admin/store-apply/${id}/approve`, data);
    }

    // 审核拒绝
    reject(id, data = {}) {
        return this.api.post(`/admin/store-apply/${id}/reject`, data);
    }

    // 获取门店分类列表
    getCategories() {
        return this.api.get('/admin/store-apply/categories');
    }

    // 批量操作
    batchApprove(ids, data = {}) {
        return this.api.post('/admin/store-apply/batch-approve', {
            ids,
            ...data
        });
    }

    // 批量拒绝
    batchReject(ids, data = {}) {
        return this.api.post('/admin/store-apply/batch-reject', {
            ids,
            ...data
        });
    }

    // 导出数据
    export(params = {}) {
        return this.api.download('/admin/store-apply/export', params, '门店申请列表.xlsx');
    }

    // 获取省市区列表
    getAddresses(level, parentId = null) {
        const params = { level };
        if (parentId) {
            params.parent_id = parentId;
        }
        return this.api.post('/admin/store/address', params);
    }

    // 获取省份列表
    getProvinces() {
        return this.getAddresses(1);
    }

    // 获取城市列表
    getCities(provinceId) {
        return this.getAddresses(2, provinceId);
    }

    // 获取区县列表
    getDistricts(cityId) {
        return this.getAddresses(3, cityId);
    }
}

// 创建全局实例
const storeApplyApi = new StoreApplyApi(window.api);
window.storeApplyApi = storeApplyApi;
